﻿#region << 文 件 说 明 >>
/*----------------------------------------------------------------
// 文件名称：IHttpClientService
// 创 建 人：YangCheng
// 创建时间：2022/7/8 9:06:16
// 文件版本：V1.0.0
// ===============================================================
// 功能描述：
//		
//
//----------------------------------------------------------------*/
#endregion

using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace Vampirewal.Core.HttpClientService
{
    /// <summary>
    /// 
    /// </summary>
    public interface IHttpClientService
    {
        ServiceProvider ServiceProvider { get; }

        IServiceCollection serviceCollection { get; }

        /// <summary>
        /// Json序列化设置
        /// </summary>
        JsonSerializerOptions options { get; }
        /// <summary>
        /// 设置Json序列化配置
        /// </summary>
        /// <param name="options"></param>
        void SetJsonSerializerOptions(JsonSerializerOptions options);

        /// <summary>
        /// 请求头字典
        /// </summary>
        Dictionary<string, string> RequestHeaderDic { get; }

        /// <summary>
        /// 设置请求头
        /// </summary>
        /// <param name="_requestHeaderDic"></param>
        void SetHeader(Dictionary<string, string> _requestHeaderDic);

        /// <summary>
        /// GET请求
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        string HttpGet(string url);

        /// <summary>
        /// GET请求（返回对象）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="url"></param>
        /// <returns></returns>
        T HttpGet<T>(string url);

        /// <summary>
        /// 自定义参数的GET请求(无需将参数自行写进url中)
        /// </summary>
        /// <param name="url">请求地址</param>
        /// <param name="requestParams">参数</param>
        /// <returns></returns>
        string RequestGetOfCustomParameter(string url, params RequestParam[] requestParams);

        /// <summary>
        /// 自定义参数的GET请求(无需将参数自行写进url中)
        /// </summary>
        /// <typeparam name="T">返回值类型</typeparam>
        /// <param name="url">请求地址</param>
        /// <param name="requestParams">参数</param>
        /// <returns></returns>
        T RequestGetOfCustomParameter<T>(string url, params RequestParam[] requestParams);

        /// <summary>
        /// 通过GET调用下载附件
        /// </summary>
        /// <param name="url"></param>
        /// <param name="SavePath"></param>
        /// <returns></returns>
        Task<bool> HttpGetDownLoad(string url, string SavePath);

        /// <summary>
        /// POST请求
        /// </summary>
        /// <param name="url">API地址</param>
        /// <param name="obj">传递的参数</param>
        /// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
        /// <param name="charset"></param>
        /// <returns>Json文本</returns>       
        string HttpPost(string url, object obj, ContentType contentType, string charset = "UTF-8");

        /// <summary>
        /// POST请求(返回对象)
        /// </summary>
        /// <param name="url">API地址</param>
        /// <param name="obj">传递的参数</param>
        /// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
        /// <param name="charset"></param>
        /// <returns>对象</returns>       
        T HttpPost<T>(string url, object obj, ContentType contentType, string charset = "UTF-8");

        /// <summary>
        /// 自定义参数的POST请求(无需将参数自行写进url中)
        /// </summary>
        /// <param name="url"></param>
        /// <param name="requestParams"></param>
        /// <returns></returns>
        string RequestPostOfCustomParameter(string url, params RequestParam[] requestParams);

        /// <summary>
        /// 自定义参数的POST请求(无需将参数自行写进url中)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="url"></param>
        /// <param name="requestParams"></param>
        /// <returns></returns>
        T RequestPostOfCustomParameter<T>(string url, params RequestParam[] requestParams);

        /// <summary>
        /// 通过POST模拟表单调用上传图片
        /// </summary>
        /// <param name="uploadUrl">请求地址</param>
        /// <param name="imgPath">图片路径</param>
        /// <param name="Param">表单参数</param>
        /// <param name="fileparameter"></param>
        /// <returns></returns>
        Task<string> PostUploadImage(string uploadUrl, string imgPath,Dictionary<string,string> Param = null, string fileparameter = "file");

        /// <summary>
        /// 模拟web表单提交
        /// </summary>
        /// <param name="url"></param>
        /// <param name="requestParams"></param>
        /// <returns></returns>
        Task<string> FormRequestPost(string url, RequestParam[] requestParams);
    }

}
